package view
{
	import data.Globals;
	import data.TankProp;
	
	import events.EventType;
	import events.GameDispatherEvent;
	import events.GameEvent;
	
	import flash.events.Event;
	import flash.geom.Point;
	
	import manager.ObjDataManage;
	import manager.ObjectPool;
	import manager.TankName;
	
	import view.base.BaseView;
	import view.base.ClearView;
	import view.tank.BaseTank;
	
	public class TankView extends ClearView
	{
		public var tankAry:Array;
		public function TankView()
		{
			super();
			tankAry = [];
		}
		
		override public function clearView():void{
			super.clearView();
			while(tankAry.length){
				var tank:BaseTank = tankAry.shift();
				tank.isCloseLoop = true;
				tank.shoutTarget = null;
			}
		}
		
		override protected function loop(event:Event):void{
			
		}
		/**
		 * 生产坦克 
		 * @param type 坦克类型
		 * @param p 坐标 Point
		 * 
		 */
		public function productionTank(type:String,p:Point):void{
			var tank:BaseTank = ObjectPool.getObj(TankName.getTankCls(type)) as BaseTank;
			this.addChild(tank);
			var tp:TankProp = ObjDataManage.getInstance().getTankProp(type);
			tank.shoutGap = tp.shoutGap;
			tank.shoutRadius = tp.shoutRadius;
			tank.bulletType = tp.bulletType;
			tank.rotateSpeed = tp.rotateSpeed;
			tank.x =p.x;
			tank.y =p.y;
			tank.isCloseLoop = false;
			tankAry.push(tank);
			Globals.gameView.calculateScore(-tp.revive);
		}
	}
}